<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>transform 的translate水平居中</title>
    <style>
        div {
            position: relative;
            width: 500px;
            height: 500px;
            /* margin: 0 auto; */
            background-color: skyblue;
        }
        
        .box {
            position: absolute;
            width: 200px;
            height: 200px;
            background-color: pink;
            left: 50%;
            top: 50%;
            transform: translate(-200px, -50%);
        }
    </style>
</head>

<body>
    <div>
        <div class="box"></div>
    </div>
</body>

</html>